home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PsL Monthly 1993 December
/
PSL Monthly Shareware CD-ROM (December 1993).iso
/
prgmming
/
dos
/
c
/
boss
/
boss_sup.lzh
/
PDDEMO.C
< prev
next >
Wrap
C/C++ Source or Header
|
1992-03-05
|
28KB
|
780 lines
/*
** DEMONSTRATION OF PULLDOWN MENU SYSTEM USING WINDOWS BOSS.
**
** Adapted, with permission, from Keith Funk's code.
**
** Copyright (C) 1992 - Philip A. Mongelluzzo
** All Rights Reserved.
**
** Contains all the code needed to implement a complete menuing system
** including active/inactive menus and menu options, toggle style options,
** multi-level pulldowns, and more.
*/
/*
** Keep everyone happy!!
*/
int DoMenu(void);
void domodem(int ch);
void dosetup(int ch);
void dofileman(int ch);
void doview(int ch);
void dographics(int Choice);
void dorun(void);
void doedit(int ch);
void dohelp(int ch);
#include "winboss.h"
int wa, ba, hka;
WNPD mainbar = {
WNLPTR, 0, 0, 0, FALSE, 0, /* Standard Preamble */
0, 6, { /* first & last selectable option */
0, 0, " File ", 'F', 1, 'A', 1, /* F = the hotkey for this option */
0, 6, " Edit ", 'E', 1, 'A', 2, /* 1 = option is active. */
0, 12, " View ", 'V', 1, 'A', 3, /* A = an action type option. */
0, 18, " Run ", 'R', 0, 'N', 4, /* N = no pulldown for this option */
0, 23, " Setup ",'S', 1, 'A', 5, /* N is only used in main menus */
0, 30, " Modem ",'M', 1, 'A', 6, /* 6 = the return code. */
0, 50, " Help ", 'H', 1, 'A', 7, /* Note that the Run option is */
99,99, "",99 } /* inactive. Selecting File/Load */
}; /* will activate it. */
WNPD pdfile = {
WNLPTR, 0, 0, 0, FALSE, 0, /* Standard Preamble */
0, 9, {
0, 0, " Load ", 'L', 1, 'A', 1,
1, 0, " Save ", 'S', 1, 'A', 2,
2, 0, " Save As ", 'A', 1, 'A', 3,
3, 0, "───────────", ' ', 0, 'A', 0, /* '─' is char ALT-196 */
4, 0, " Chdir ", 'C', 1, 'A', 4,
5, 0, "───────────", ' ', 0, 'A', 0, /* not an option, Must be inactive. */
6, 0, " Print ", 'P', 0, 'A', 5,
7, 0, "───────────", ' ', 0, 'A', 0,
8, 0, " DOS Shell ", 'D', 0, 'A', 6, /* 0 = inactive menu option */
9, 0, " Exit ", 'x', 1, 'A', 7, /* hotkeys are case sensitive */
99, 99, "",99 }
};
WNPD pdedit = {
WNLPTR, 0, 0, 0, FALSE, 0, /* Standard Preamble */
0, 2, {
0, 0, " Cut ", 't', 1, 'A', 1, /* Paste is inactive. */
1, 0, " Copy ", 'C', 1, 'A', 2, /* NEVER de-activate a main menu */
2, 0, " Paste ", 'P', 0, 'A', 3, /* option that has a pulldown. */
99, 99, "",99 } /* De-activate the pulldown instead*/
}; /* so user can see, but not select */
WNPD pdview = {
WNLPTR, 0, 0, 0, FALSE, 0, /* Standard Preamble */
0, 2, {
0, 0, " Input ", 'I', 0, 'A', 1, /* all initially inactive, but */
1, 0, " Output ", 'O', 0, 'A', 2, /* will be activated by user */
2, 0, " Graphics ", 'G', 0, 'A', 3, /* selecting File/Load and Run */
99, 99, "",99 } /* menu options. */
};
WNPD pdsetup = {
WNLPTR, 0, 0, 0, FALSE, 0, /* Standard Preamble */
0, 2, {
0, 0, " Color ", 'C', 1, 'T', 1, /* T = a non-exclusive toggle. */
1, 0, " Printer ", 'P', 1, 'A', 2,
2, 0, " Plotter ", 'l', 1, 'A', 3,
99, 99, "",99 }
};
WNPD pdmodem = {
WNLPTR, 0, 0, 0, FALSE, 0, /* Standard Preamble */
0, 1, {
0, 0, " Receive ", 'R', 1, 'A', 1,
1, 0, " Send ", 'S', 1, 'A', 2,
2, 0, "────────────", ' ', 0, 'A', 0, /* comments must be specified */
3, 0, " MODEM MUST ", ' ', 0, 'A', 0, /* as inactive. */
4, 0, " BE ON ", ' ', 0, 'A', 0,
99, 99, "",99 }
};
WNPD pdhelp = {
WNLPTR, 0, 0, 0, FALSE, 0, /* Standard Preamble */
0, 3, {
0, 0, " Contents ", 'C', 1, 'A', 1,
1, 0, " Index ", 'I', 1, 'A', 2,
2, 0, " Topic F1 ", 'T', 1, 'A', 3,
3, 0, " Help On Help ", 'H', 1, 'A', 4,
99, 99, "",99 }
};
WNPD pdprinters = {
WNLPTR, 0, 0, 0, FALSE, 0, /* Standard Preamble */
0, 4, {
0, 0, " Amdex ", 'A', 1, 'E', 1, /* E = mutually Exclusive toggles */
1, 0, " Epson ", 'E', 1, 'E', 2, /* only one can be ON at a time. */
2, 0, " HP ", 'H', 1, 'E', 3,
3, 0, " Roland ", 'R', 1, 'E', 4,
4, 0, " QMS ", 'Q', 1, 'E', 5,
5, 0, "────────", ' ', 0, 'A', 0,
6, 0, " ESC TO ", ' ', 0, 'A', 0,
7, 0, " EXIT ", ' ', 0, 'A', 0,
99, 99, "",99}
};
WNPD pdgraph = {
WNLPTR, 0, 0, 0, FALSE, 0, /* Standard Preamble */
0, 3, {
0, 0, " X Axis ", 'X', 1, 'A', 1,
1, 0, " Y Axis ", 'Y', 1, 'A', 2,
2, 0, " Options ", 'O', 1, 'A', 3,
3, 0, " Draw Graph ", 'D', 0, 'A', 4, /* inactive tell X & Y selected */
99, 99, "",99 }
};
WNPD pdxaxis = {
WNLPTR, 0, 0, 0, FALSE, 0, /* Standard Preamble */
0, 4, {
0, 0, " Time ", 'T', 1, 'E', 1,
1, 0, " Stress ", 'S', 1, 'E', 2, /* duplicate items in */
2, 0, " Strain ", 'r', 1, 'E', 3, /* this menu and the X */
3, 0, " Axial Load ", 'A', 1, 'E', 4, /* axis menu MUST have */
4, 0, " Lateral Load ", 'L', 1, 'E', 5, /* the same return code. */
99, 99, "",99}
};
WNPD pdyaxis = {
WNLPTR, 0, 0, 0, FALSE, 0, /* Standard Preamble */
2, 7, {
0, 0, " SELECT ONE OR MORE ", ' ', 0, 'A', 0,
1, 0, "────────────────────", ' ', 0, 'A', 0,
2, 0, " Stress ", 'S', 1, 'T', 2,
3, 0, " Strain ", 'r', 1, 'T', 3,
4, 0, " Axial Load ", 'A', 1, 'T', 4,
5, 0, " Lateral Load ", 'L', 1, 'T', 5,
6, 0, " Transducer Voltage ", 'V', 1, 'T', 6,
7, 0, " Clear All Options ", 'C', 1, 'A', 7,
99, 99, "",99}
};
main()
{
unsigned int ch;
WINDOWPTR mainwin, msgwin;
int i;
int AllDone = 0; /* 1 = exit program */
wn_init(); /* save entry screen */
v_cls(NVIDEO); /* clear screen */
wn_border(1); /* single ruled border */
/*
** window for main program to execute in
*/
mainwin = wn_open(0, 1, 0, 78, 21, v_setatr(BLUE,WHITE,0,BOLD), NVIDEO);
/*
** window to display messages
*/
msgwin = wn_open(1000, 24,0,80,1, v_setrev(NVIDEO), v_setrev(NVIDEO));
wa = v_setatr(WHITE,BLACK,0,0); /* window attirbute. */
ba = v_setatr(WHITE,BLACK,0,0); /* border attribute. */
hka = v_setatr(WHITE,WHITE,0,BOLD); /* hotkey attribute. */
/*
** Menu Bar
*/
wn_pdopen(1000,0,0,80,1,wa,ba,hka, &mainbar, FALSE);
/*
** Explain a bit about the demo program.
*/
wn_puts(mainwin, 1, 13, " PULLDOWN MENU DEMO PROGRAM");
wn_puts(mainwin, 3, 13, "1. Run is inactive until you select File/Load.");
wn_puts(mainwin, 4, 13, "2. The View options are activated by File/Load and Run.");
wn_puts(mainwin, 5, 13, "3. Edit/Paste and File/DOS options are never activated.");
wn_puts(mainwin, 6, 13, "4. Setup/Printers activates the File/Print option.");
wn_puts(mainwin, 7, 13, "5. Selecting X and Y axis options, activates Display Graph.");
wn_puts(mainwin, 8, 13, "6. When a pulldown menu is active, use the left/right");
wn_puts(mainwin, 9, 13, " arrow keys to view others. Run has no pulldown menu.");
/*
** Provide instructions on message line...
*/
wn_puts(msgwin, 0, 1, "<Slash Key '/' Activates The Menu>");
/*
** main program loop. Does nothing practical. Simply displays a moving
** counter to show that the program is doing something until the
** user activates the menu.
*/
i = 0;
while (!AllDone)
{
while (!v_kstat()) /* do stuff until key hit */
{
wn_locate(mainwin, 12, 26);
wn_printf(mainwin, "Main Program Is Running %5d", i);
i = (++i > 32000) ? 0 : i;
}
ch = (v_getch() & 0x7F); /* get the key pressed. */
if (ch == '/') /* activate the menu */
{
wn_clr(msgwin);
wn_puts(msgwin, 0, 1, "<ESC Exits Menus> <Any Key Exits Messages>");
wn_locate(mainwin, 12, 26);
wn_printf(mainwin, " ");